{extend name="base" /}
{block name="title"}
<title>修改手机号-{$site_config.site_title}</title>
{/block}
{block name="body"}
<style type="text/css">
.btn_code{width: 100%;margin: 0 auto;float: left;padding: 10px 0;background: #ec5e2a;color: #fff;text-align: center;border-radius: 5px;}
</style>
	<header class="page-header1">
		<a href="javascript:;" onClick="javascript:history.back(-1);"><img src="__STATIC__/img/back02.png" class="back_img" style="float:left;"/></a>
		<h3>修改手机号</h3>
	</header>
	<form id="h-form">
	<div class="modify_phone">
		<div class="modify_phone_center">
			<div class="input_phone">
				<input type="text" placeholder="新手机号" class="new_phone" name="mobile" id="mobile" />
			</div>
			<div class="input_verification">
				<div class="input_verification_code">
					<input type="text" placeholder="验证码" class="new_code" id="new_code" name="code"/>
				</div>
				<div class="input_verification_code_btn code">
					<span id="timeObtain" class="btn_code" >获取验证码</span>
				</div>
			</div>
		</div>
		<div class="btn_confirms">
			<div class="btn_confirm_code" id="h-submit" disabled='disabled'>确认修改</div>
			<!-- <button id="h-submit" class="btn_modify" style="padding:10% 0;" disabled='disabled'>确认修改</button> -->
		</div>
	</div>
	</form>
	<script type="text/javascript">
    window.onload =function()
    {
        document.getElementById("h-submit").style.backgroundImage ="url(__STATIC__/img/btn_code01.png)";
        document.getElementById("h-submit").style.backgroundSize ="100% 100%";
        //鼠标悬停在按钮上时判断。
        document.getElementById("new_code").onkeyup = function()
        {
            if(document.getElementById("new_code").value=="")
            {
                document.getElementById("h-submit").style.backgroundImage ="url(__STATIC__/img/btn_code01.png)";
                document.getElementById("h-submit").style.backgroundSize ="100% 100%";
                document.getElementById("h-submit").innerHTML="确定";
            }else
            {
                document.getElementById("h-submit").style.backgroundImage ="url(__STATIC__/img/btn_code02.png)";
                document.getElementById("h-submit").style.backgroundSize ="100% 100%";
                document.getElementById("h-submit").style.color ="#fff";
                document.getElementById("h-submit").innerHTML="确定";
            }
        }
    }
    </script>
    <!-- <script type="text/javascript">
    	/*获取手机号*/
    	function code(){
    		var pd=/^1\d{10}$/;
    		if(pd.test($("#mobile").val())){
    			$(".code span").removeAttr("onclick");
    			$.ajax({
    				url:"{:url('Home/MobileCode/getChangeMobileCode')}",
    				type:"POST",
    				data:{mobile:$("#mobile").val()},
    				dataType:"json",
    				success:function(data){
    					// 发送成功
    					if(data.status == 1) {
    			            dialog.error(data.message,data.url);
    			            $(".code span").css({"background":"#ddd","color":"#444"}).html("60秒重新发送").unbind("click");
    						var num=59;
    						var time=setInterval(function(){
    							$(".code span").html(num-- + "s后重新发送");
    							if(num<0){
    								clearTimeout(time);
    								$(".code span").css({"background":"#ec5e2a","color":"#fff"}).html("重新发送");
    								$(".code span").attr("onclick","code()");
    							}
    						},1000);
    			        }else if(data.status == 0) {
    			            // 失败
    			            dialog.error(data.message,data.url);
    			            $(".code span").attr("onclick","code()");
    			            return false;
    			        }
    				}
    			})
    		}else{
    			dialog.error("手机号码不正确");
    		}
    	}
    </script> -->
    <script type="text/javascript">
	$("#timeObtain").click(function(){
		var pd=/^1\d{10}$/;
        if(pd.test($("#mobile").val())){
            $(".code span").removeAttr("onclick");
            $.ajax({
                url:"{:url('Home/MobileCode/getChangeMobileCode')}",
                type:"POST",
                data:{mobile:$("#mobile").val()},
                dataType:"json",
                success:function(data){
                    // 发送成功
                    if(data.status == 1) {
                        dialog.error(data.message,data.url);
                        $(".code span").css({"background":"#ddd","color":"#444"}).html("60秒重新发送").unbind("click");
                        var num=59;
                        var time=setInterval(function(){
                            $(".code span").html(num-- + "s后重新发送");
                            if(num<0){
                                clearTimeout(time);
                                $(".code span").css({"background":"#ec5e2a","color":"#fff"}).html("重新发送");
                                //$(".code span").attr("onclick","code()");
                            }
                        },1000);
                    }else if(data.status == 0) {
                        // 失败
                        dialog.error(data.message,data.url);
                        //$(".code span").attr("onclick","code()");
                        return false;
                    }
                }
            })
        }else{
            dialog.error("请输入正确的手机号码");
        }
	});

    </script>
    {include file="public/menu" /}
    {include file="public/submit" /}
{/block}

